<template>
  <div>
    <div class="header_search_nav search_form">
      <div class="ipt_left">
        <el-form ref="queryForm" :model="queryParams" label-width="100px">
          <el-row>
            <el-col :span="5">
              <div class="timebox">
                <el-form-item label="门店" prop="storeId">
                  <el-select
                    v-model="queryParams.storeId"
                    placeholder="请选择"
                    class="w-200"
                    filterable
                  >
                    <el-option
                      v-for="item in this.$store.state.user.stores"
                      :key="item.id"
                      :label="item.name"
                      :value="item.id"
                    >
                    </el-option>
                  </el-select>
                </el-form-item>
              </div>
            </el-col>
            <el-col :span="5">
              <div class="timebox">
                <el-form-item label="名称" prop="userName">
                  <el-input
                    v-model="queryParams.userName"
                    placeholder="请输入"
                    class="w-200"
                  ></el-input>
                </el-form-item>
              </div>
            </el-col>
            <el-col :span="5">
              <div class="timebox">
                <el-form-item label="月份" prop="wagesMoon">
                  <el-date-picker
                    v-model="queryParams.wagesMoon"
                    type="month"
                    placeholder="选择月"
                    value-format="yyyy-MM"
                    class="w-160"
                  >
                  </el-date-picker>
                </el-form-item>
              </div>
            </el-col>
          </el-row>
        </el-form>
      </div>

      <div class="btn_right">
        <button class="btn1" @click="handleQuery">筛选</button>
        <button class="btn2" @click="resetQuery">重置</button>
      </div>
    </div>

    <div class="table_card">
      <!-- 上部分 title -->
      <div class="table_card_top">
        <span class="solid_left"></span>
        <div class="table_card_title">店长工资</div>
      </div>

      <div class="table_list">
        <el-table :data="tableData" stripe style="width: 100%">
          <el-table-column prop="wagesMoon" label="工资月份"> </el-table-column>
          <el-table-column prop="dptName" label="门店名称" width="160px">
          </el-table-column>
          <el-table-column prop="nickname" label="姓名"> </el-table-column>
          <el-table-column
            prop="hiredate"
            label="入职日期"
            width="120px"
          ></el-table-column>
          <el-table-column prop="postName" label="岗位" width="120px">
          </el-table-column>
          <!-- <el-table-column
            prop="basicMoney"
            label="基本工资"
            width="120px"
          ></el-table-column> -->
          <el-table-column
            prop="workDayWant"
            label="应出勤"
            width="100px"
          ></el-table-column>
          <el-table-column
            prop="workDayReal"
            label="实际出勤"
            width="140px"
          ></el-table-column>
          <el-table-column
            prop="basicWorkMoney"
            label="考勤工资"
            width="150px"
          ></el-table-column>
          <!-- <el-table-column prop="workHour" label="加班时长"></el-table-column> -->
          <!-- <el-table-column
            prop="workMoney"
            label="加班工资"
            width="110px"
          ></el-table-column> -->
          <el-table-column
            prop="rechargeMoney"
            label="充卡业绩"
          ></el-table-column>
          <el-table-column
            prop="rechargeAwardMoney"
            label="充卡业绩提成"
            width="150"
          ></el-table-column>
          <!-- <el-table-column
            prop="otherMoneyAdd"
            label="其他奖金"
            width="120px"
          ></el-table-column>
          <el-table-column
            prop="otherMoneySub"
            label="其他扣款"
          ></el-table-column> -->
          <el-table-column
            prop="storePoMoney"
            label="门店业绩"
          ></el-table-column>
          <el-table-column prop="poMoney" label="业绩提成"></el-table-column>
          <!-- <el-table-column prop="bonusMoney" label="奖金"></el-table-column> -->
          <el-table-column
            prop="postAllowanceMoney"
            label="岗位津贴"
          ></el-table-column>
          <!-- <el-table-column
            prop="workYearMoney"
            label="工龄工资"
          ></el-table-column>
          <el-table-column
            prop="trainSubsidyMoney"
            label="培训补助"
          ></el-table-column>
          <el-table-column
            prop="trainAwardMoney"
            label="培训提成"
          ></el-table-column> -->
          <el-table-column prop="online" label="线上转化率" width="110px">
            <template slot-scope="scope">
              <div>{{ scope.row.online }}%</div>
            </template>
          </el-table-column>
          <el-table-column
            prop="onlineMoney"
            label="线上转化率(绩效)"
            width="130px"
          >
          </el-table-column>
          <el-table-column prop="mtGood" label="美团好评率" width="110px">
            <template slot-scope="scope">
              <div>{{ scope.row.mtGood }}%</div>
            </template>
          </el-table-column>
          <el-table-column
            prop="mtGoodMoney"
            label="美团好评率(绩效)"
            width="130px"
          ></el-table-column>
          <el-table-column prop="hire" label="自招"> </el-table-column>
          <el-table-column
            prop="hireMoney"
            label="自招(绩效)"
            width="130px"
          ></el-table-column>
          <el-table-column prop="dyGood" label="抖音好评率" width="110px">
            <template slot-scope="scope">
              <div>{{ scope.row.dyGood }}%</div>
            </template>
          </el-table-column>
          <el-table-column
            prop="dyGoodMoney"
            label="抖音好评率(绩效)"
            width="130px"
          ></el-table-column>
          <el-table-column prop="bad" label="综合差评率" width="110px">
            <template slot-scope="scope">
              <div>{{ scope.row.bad }}%</div>
            </template>
          </el-table-column>
          <el-table-column
            prop="badMoney"
            label="综合差评率(绩效)"
            width="130px"
          ></el-table-column>
          <el-table-column prop="totalMoney" label="总工资"></el-table-column>

          <el-table-column label="操作" width="250">
            <template slot-scope="scope">
              <el-button
                size="mini"
                type="text"
                @click="UpdatestoreManagerPayrolls(scope.row)"
                >更新工资单</el-button
              >
            </template>
          </el-table-column>
        </el-table>
        <pagination
          :total="total"
          :page.sync="queryParams.pageNo"
          :limit.sync="queryParams.pageSize"
          @pagination="getList"
        />
      </div>

      <!-- 工资单 -->
      <el-dialog
        :title="titleNav"
        :visible.sync="PayrollVis"
        width="800px"
        class="no-dialog-padding"
        @close="PayrollCancle"
      >
        <div class="setItem">
          <el-form
            :model="PayrollForm"
            :rules="PayrollRules"
            ref="PayrollForm"
            label-width="140px"
            class="demo-ruleForm"
          >
            <el-row :gutter="24">
              <!-- {{ PayrollForm }} -->
              <el-col :span="12" v-if="!Payrolledit">
                <el-form-item label="用户" prop="userId">
                  <el-select
                    class="w-100"
                    v-model="PayrollForm.userId"
                    placeholder="请输入"
                    filterable
                    :clearable="true"
                  >
                    <el-option
                      v-for="item in userWorksList"
                      :key="item.id"
                      :label="`${item.nickname}`"
                      :value="item.id"
                    />
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="12" v-if="Payrolledit">
                <el-form-item label="用户" prop="userName">
                  <el-input
                    :disabled="true"
                    v-model="PayrollForm.userName"
                    :controls="false"
                    class="w-100 text-left"
                    label="请输入"
                    placeholder="请输入"
                  ></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="12" v-if="!Payrolledit">
                <el-form-item label="部门" prop="dptId">
                  <treeselect
                    class="w-100"
                    v-model="PayrollForm.dptId"
                    :options="deptOptions"
                    :show-count="true"
                    :clearable="false"
                    placeholder="请选择部门"
                    :normalizer="normalizer"
                  />
                </el-form-item>
              </el-col>
              <el-col :span="12" v-if="Payrolledit">
                <el-form-item label="部门" prop="dptName">
                  <el-input
                    v-model="PayrollForm.dptName"
                    :controls="false"
                    class="w-100 text-left"
                    label="请输入"
                    placeholder="请输入"
                    :disabled="true"
                  ></el-input>
                </el-form-item>
              </el-col>
            </el-row>

            <el-row :gutter="24">
              <el-col :span="12" v-if="!Payrolledit">
                <el-form-item label="岗位" prop="postId">
                  <el-select
                    v-model="PayrollForm.postId"
                    placeholder="请选择"
                    class="w-100"
                    filterable
                  >
                    <el-option
                      v-for="item in UserOptions"
                      :key="item.id"
                      :label="item.name"
                      :value="item.id"
                    />
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="12" v-if="Payrolledit">
                <el-form-item label="岗位" prop="postName">
                  <el-input
                    v-model="PayrollForm.postName"
                    :controls="false"
                    class="w-100 text-left"
                    label="请输入"
                    placeholder="请输入"
                    :disabled="true"
                  ></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="工资月份" prop="wagesMoon">
                  <el-date-picker
                    v-model="PayrollForm.wagesMoon"
                    type="month"
                    placeholder="选择工资月份"
                    :value-format="'yyyy-MM-dd'"
                  >
                  </el-date-picker>
                </el-form-item>
              </el-col>
            </el-row>

            <el-row :gutter="24">
              <el-col :span="12">
                <el-form-item label="应出勤" prop="workDayWant">
                  <el-input-number
                    v-model="PayrollForm.workDayWant"
                    :controls="false"
                    class="w-100 text-left"
                    :min="0"
                    :max="10000000"
                    label="请输入"
                    placeholder="请输入"
                  ></el-input-number>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="实际出勤" prop="workDayReal">
                  <el-input-number
                    v-model="PayrollForm.workDayReal"
                    :controls="false"
                    class="w-100 text-left"
                    :min="0"
                    :max="10000000"
                    label="请输入"
                    placeholder="请输入"
                  ></el-input-number>
                </el-form-item>
              </el-col>
            </el-row>

            <el-row :gutter="24">
              <el-col :span="12">
                <el-form-item label="基本工资" prop="basicMoney">
                  <el-input-number
                    v-model="PayrollForm.basicMoney"
                    :controls="false"
                    class="w-100 text-left"
                    :min="0"
                    :max="10000000"
                    label="请输入"
                    placeholder="请输入"
                  ></el-input-number>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="考勤工资" prop="basicWorkMoney">
                  <el-input-number
                    v-model="PayrollForm.basicWorkMoney"
                    :controls="false"
                    class="w-100 text-left"
                    :min="0"
                    :max="10000000"
                    label="请输入"
                    placeholder="请输入"
                  ></el-input-number>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row :gutter="24">
              <el-col :span="12">
                <el-form-item label="加钟提成" prop="clockAddMoney">
                  <el-input-number
                    v-model="PayrollForm.clockAddMoney"
                    :controls="false"
                    class="w-100 text-left"
                    :min="0"
                    :max="10000000"
                    label="请输入"
                    placeholder="请输入"
                  ></el-input-number>
                </el-form-item>
              </el-col>

              <el-col :span="12">
                <el-form-item label="点钟提成" prop="clockSpotMoney">
                  <el-input-number
                    v-model="PayrollForm.clockSpotMoney"
                    :controls="false"
                    class="w-100 text-left"
                    :min="0"
                    :max="10000000"
                    label="请输入"
                    placeholder="请输入"
                  ></el-input-number>
                </el-form-item>
              </el-col>
            </el-row>

            <el-row :gutter="24">
              <el-col :span="12">
                <el-form-item label="约客提成" prop="visitorMoney">
                  <el-input-number
                    v-model="PayrollForm.visitorMoney"
                    :controls="false"
                    class="w-100 text-left"
                    :min="0"
                    :max="10000000"
                    label="请输入"
                    placeholder="请输入"
                  ></el-input-number>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="待客提成" prop="hospitalityMoney">
                  <el-input-number
                    v-model="PayrollForm.hospitalityMoney"
                    :controls="false"
                    class="w-100 text-left"
                    :min="0"
                    :max="10000000"
                    label="请输入"
                    placeholder="请输入"
                  ></el-input-number>
                </el-form-item>
              </el-col>
            </el-row>

            <el-row :gutter="24">
              <el-col :span="12">
                <el-form-item label="业绩(技师)" prop="rechargeMoney">
                  <el-input-number
                    v-model="PayrollForm.rechargeMoney"
                    :controls="false"
                    class="w-100 text-left"
                    :min="0"
                    :max="10000000"
                    label="请输入"
                    placeholder="请输入"
                  ></el-input-number>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="业绩提成(技师)" prop="rechargeAwardMoney">
                  <el-input-number
                    v-model="PayrollForm.rechargeAwardMoney"
                    :controls="false"
                    class="w-100 text-left"
                    :min="0"
                    :max="10000000"
                    label="请输入"
                    placeholder="请输入"
                  ></el-input-number>
                </el-form-item> </el-col
            ></el-row>

            <el-row :gutter="24">
              <el-col :span="12">
                <el-form-item label="手工提成" prop="hardAwardMoney">
                  <el-input-number
                    v-model="PayrollForm.hardAwardMoney"
                    :controls="false"
                    class="w-100 text-left"
                    :min="0"
                    :max="10000000"
                    label="请输入"
                    placeholder="请输入"
                  ></el-input-number>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="手工额外提成" prop="hardAwardExtMoney">
                  <el-input-number
                    v-model="PayrollForm.hardAwardExtMoney"
                    :controls="false"
                    class="w-100 text-left"
                    :min="0"
                    :max="10000000"
                    label="请输入"
                    placeholder="请输入"
                  ></el-input-number>
                </el-form-item>
              </el-col>
            </el-row>

            <el-row :gutter="24">
              <el-col :span="12">
                <el-form-item label="业绩提成(店长)" prop="poMoney">
                  <el-input-number
                    v-model="PayrollForm.poMoney"
                    :controls="false"
                    class="w-100 text-left"
                    :min="0"
                    :max="10000000"
                    label="请输入"
                    placeholder="请输入"
                  ></el-input-number>
                </el-form-item>
              </el-col>
              <!-- <el-col :span="12">
                <el-form-item label="奖金(店长)" prop="bonusMoney">
                  <el-input-number
                    v-model="PayrollForm.bonusMoney"
                    :controls="false"
                    class="w-100 text-left"
                    :min="0"
                    :max="10000000"
                    label="请输入"
                    placeholder="请输入"
                  ></el-input-number>
                </el-form-item>
              </el-col> -->
              <el-col :span="12">
                <el-form-item label="岗位津贴" prop="postAllowanceMoney">
                  <el-input-number
                    v-model="PayrollForm.postAllowanceMoney"
                    :controls="false"
                    class="w-100 text-left"
                    :min="0"
                    :max="10000000"
                    label="请输入"
                    placeholder="请输入"
                  ></el-input-number>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="线上转化率" prop="online">
                  <div class="percentBox">
                    <div class="IptNumber">
                      <el-input-number
                        v-model="PayrollForm.online"
                        :controls="false"
                        class="w-100 text-left"
                        :min="0"
                        :max="10000000"
                        label="请输入"
                        placeholder="请输入"
                      ></el-input-number>
                    </div>
                    <div class="">%</div>
                  </div>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="线上转化率(绩效)" prop="onlineMoney">
                  <el-input-number
                    v-model="PayrollForm.onlineMoney"
                    :controls="false"
                    class="w-100 text-left"
                    :min="0"
                    :max="10000000"
                    label="请输入"
                    placeholder="请输入"
                  ></el-input-number>
                </el-form-item>
              </el-col>
            </el-row>

            <el-row :gutter="24">
              <el-col :span="12">
                <el-form-item label="美团好评率" prop="mtGood">
                  <div class="percentBox">
                    <div class="IptNumber">
                      <el-input-number
                        v-model="PayrollForm.mtGood"
                        :controls="false"
                        class="w-100 text-left"
                        :min="0"
                        :max="10000000"
                        label="请输入"
                        placeholder="请输入"
                      ></el-input-number>
                    </div>
                    <div class="">%</div>
                  </div>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="美团好评率(绩效)" prop="mtGoodMoney">
                  <el-input-number
                    v-model="PayrollForm.mtGoodMoney"
                    :controls="false"
                    class="w-100 text-left"
                    :min="0"
                    :max="10000000"
                    label="请输入"
                    placeholder="请输入"
                  ></el-input-number>
                </el-form-item>
              </el-col>
            </el-row>

            <el-row :gutter="24">
              <el-col :span="12">
                <el-form-item label="抖音好评率" prop="dyGood">
                  <div class="percentBox">
                    <div class="IptNumber">
                      <el-input-number
                        v-model="PayrollForm.dyGood"
                        :controls="false"
                        class="w-100 text-left"
                        :min="0"
                        :max="10000000"
                        label="请输入"
                        placeholder="请输入"
                      ></el-input-number>
                    </div>
                    <div class="">%</div>
                  </div>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="抖音好评率(绩效)" prop="dyGoodMoney">
                  <el-input-number
                    v-model="PayrollForm.dyGoodMoney"
                    :controls="false"
                    class="w-100 text-left"
                    :min="0"
                    :max="10000000"
                    label="请输入"
                    placeholder="请输入"
                  ></el-input-number>
                </el-form-item>
              </el-col>
            </el-row>

            <el-row :gutter="24">
              <el-col :span="12">
                <el-form-item label="综合差评率" prop="bad">
                  <div class="percentBox">
                    <div class="IptNumber">
                      <el-input-number
                        v-model="PayrollForm.bad"
                        :controls="false"
                        class="w-100 text-left"
                        :min="0"
                        :max="10000000"
                        label="请输入"
                        placeholder="请输入"
                      ></el-input-number>
                    </div>
                    <div class="">%</div>
                  </div>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="综合差评率(绩效)" prop="badMoney">
                  <el-input-number
                    v-model="PayrollForm.badMoney"
                    :controls="false"
                    class="w-100 text-left"
                    :min="0"
                    :max="10000000"
                    label="请输入"
                    placeholder="请输入"
                  ></el-input-number>
                </el-form-item>
              </el-col>
            </el-row>

            <el-row :gutter="24">
              <el-col :span="12">
                <el-form-item label="自招" prop="hire">
                  <el-input-number
                    v-model="PayrollForm.hire"
                    :controls="false"
                    class="w-100 text-left"
                    :min="0"
                    :max="10000000"
                    label="请输入"
                    placeholder="请输入"
                  ></el-input-number>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="自招(绩效)" prop="hireMoney">
                  <el-input-number
                    v-model="PayrollForm.hireMoney"
                    :controls="false"
                    class="w-100 text-left"
                    :min="0"
                    :max="10000000"
                    label="请输入"
                    placeholder="请输入"
                  ></el-input-number>
                </el-form-item>
              </el-col>
            </el-row>
          </el-form>
        </div>

        <div slot="footer" class="dialog-footer">
          <el-button @click="PayrollCancle">取消</el-button>
          <el-button
            type="primary"
            :loading="PayrollLoading"
            @click="PayrollSave"
            >确认</el-button
          >
        </div>
      </el-dialog>
    </div>
  </div>
</template>

<script>
import { StoreWages } from "@/api/bpm/completeValue";
import {
  UpdateWages,
  getListAllSimple,
  getUserWork,
  listSimpleDepts,
  getPostSimpleList,
  getWagesInfo,
} from "@/api/bpm/Payroll";
export default {
  name: "Eryuoastorecontribution",

  data() {
    return {
      tableData: [],
      queryParams: {
        pageNo: 1,
        pageSize: 10,
        storeId: "",
        userName: "",
        wagesMoon: "",
      },
      total: 0,

      PayrollVis: false,
      Payrolledit: false,
      titleNav: "",
      PayrollLoading: false,
      PayrollForm: {
        basicMoney: "",
        basicWorkMoney: "",
        clockAddMoney: "",
        clockSpotMoney: "",
        dptId: "",
        hardAwardExtMoney: "",
        hardAwardMoney: "",
        hardMoney: "",
        hospitalityMoney: "",
        rechargeAwardMoney: "",
        rechargeMoney: "",
        totalMoney: "",
        visitorMoney: "",
        wagesId: "",
        workDayReal: "",
        workDayWant: "",
        poMoney: "",
        // bonusMoney: "",
        postAllowanceMoney: "",
        // workYearMoney: "",
        // trainSubsidyMoney: "",
        // trainAwardMoney: "",
        dptId: null,
        postId: "", // 岗位
        postName: "",
        userId: "",
        userName: "",
        dptName: "",
        wagesMoon: "", // 工资月份

        online: 0,
        onlineMoney: 0,
        mtGood: 0,
        mtGoodMoney: 0,
        dyGood: 0,
        dyGoodMoney: 0,
        bad: 0,
        badMoney: 0,
        hire: 0,
        hireMoney: 0,
      },
      PayrollRules: {
        userId: [{ required: true, message: "请选择", trigger: "change" }],
        postId: [{ required: true, message: "请选择", trigger: "change" }],
        dptId: [{ required: true, message: "请选择", trigger: "change" }],
        wagesMoon: [{ required: true, message: "请选择", trigger: "change" }],
        mtGood: [{ required: true, message: "请输入", trigger: "change" }],
        mtGoodMoney: [{ required: true, message: "请输入", trigger: "change" }],
        online: [{ required: true, message: "请输入", trigger: "change" }],
        onlineMoney: [{ required: true, message: "请输入", trigger: "change" }],
      },

      deptOptions: [],
      UserOptions: [],
      userWorksList: [],
    };
  },

  // 监听searchMonth 变化 就调取getList
  watch: {
    "queryParams.wagesMoon"(val) {
      this.queryParams.pageNo = 1;
      this.getList();
    },
  },

  created() {
    this.getListAllSimpleData();
    this.getTreeselect();
    this.getPostSimpleData();
    // this.getSalaryTypeLists();
    const today = new Date();
    const lastMonth = new Date(today.getFullYear(), today.getMonth() - 1);
    this.queryParams.wagesMoon = `${lastMonth.getFullYear()}-${(
      lastMonth.getMonth() + 1
    )
      .toString()
      .padStart(2, "0")}`;
  },

  mounted() {},

  methods: {
    // 工资单详情
    getWagesDetailInfo(row) {
      getWagesInfo({
        wagesId: row.wagesId,
        dptId: row.dptId,
      })
        .then((res) => {
          const { code, data } = res;
          if (code === 0) {
            this.PayrollForm = {
              basicMoney: data.basicMoney,
              basicWorkMoney: data.basicWorkMoney,
              clockAddMoney: data.clockAddMoney,
              clockSpotMoney: data.clockSpotMoney,
              dptId: data.dptId,
              wagesId: data.wagesId,
              hardAwardExtMoney: data.hardAwardExtMoney,
              hardAwardMoney: data.hardAwardMoney,
              hardMoney: data.hardMoney,
              hospitalityMoney: data.hospitalityMoney,
              rechargeAwardMoney: data.rechargeAwardMoney,
              rechargeMoney: data.rechargeMoney,
              totalMoney: data.totalMoney,
              visitorMoney: data.visitorMoney,
              workDayReal: data.workDayReal,
              workDayWant: data.workDayWant,
              poMoney: data.poMoney,
              postAllowanceMoney: data.postAllowanceMoney,

              postId: data.postId, // 岗位
              postName: data.postName,
              userId: data.userId,
              userName: data.userName,
              dptName: data.dptName,
              wagesMoon: data.wagesMoon, // 工资月份

              online: data.online,
              onlineMoney: data.onlineMoney,
              mtGood: data.mtGood,
              mtGoodMoney: data.mtGoodMoney,
              dyGood: data.dyGood,
              dyGoodMoney: data.dyGoodMoney,
              bad: data.bad,
              badMoney: data.badMoney,
              hire: data.hire,
              hireMoney: data.hireMoney,
            };

            console.log(data, "dsdsdsd");
          }
        })
        .catch((err) => {});
    },
    // 岗位
    getListAllSimpleData() {
      getListAllSimple()
        .then((res) => {
          const { code, data } = res;
          if (code === 0) {
            this.PostOptions = data;
          }
        })
        .catch((err) => {});
    },
    normalizer(node) {
      return {
        id: node.id,
        label: node.name,
        children: node.children,
      };
    },
    // 获得精简岗位列表
    getPostSimpleData() {
      getPostSimpleList({}).then((response) => {
        this.UserOptions = response.data;
      });
    },
    getTreeselect() {
      // 原来的获取组织接口
      listSimpleDepts().then((response) => {
        // 处理 deptOptions 参数
        this.deptOptions = [];
        this.deptOptions.push(...this.handleTree(response.data, "id"));

        let Item = {};
        for (let i = 0; i < response.data.length; i++) {
          let item = response.data[i];
          Item[item.id] = item.name;
        }
        this.deptNames = Item;
      });
    },
    getUsers() {
      getUserWork({}).then((res) => {
        console.log(res, "dsfksdlkfl");
        this.userWorksList = res.data;
      });
    },
    PayrollCancle() {
      this.resetFormData("PayrollForm");
      this.$nextTick(() => {
        this.PayrollVis = false;
      });
    },
    PayrollSave() {
      if (this.PayrollLoading) {
        return false;
      }

      this.$refs["PayrollForm"].validate((valid) => {
        if (valid) {
          this.PayrollLoading = true;
          this.UpdateWagesAction();
        }
      });
    },

    // 更新工资单
    UpdateWagesAction() {
      UpdateWages(this.PayrollForm)
        .then((res) => {
          this.PayrollLoading = false;
          const { code } = res;
          if (code === 0) {
            this.getList();
            this.$message.success("操作成功");
            this.PayrollCancle();
          }
        })
        .catch(() => {
          this.PayrollLoading = false;
        });
    },

    UpdatestoreManagerPayrolls(row) {
      this.PayrollVis = true;
      this.Payrolledit = true;
      this.titleNav = "更新工资单";
      this.getWagesDetailInfo(row);
    },
    // 搜索
    TrainingListQuery() {
      this.queryParams.pageNo = 1;
      this.getUserInterviewer();
    },

    // 重置
    TrainingListReset() {
      this.TrainingListQuery();
    },

    resQ() {
      this.queryParams.pageNo = 1;
      this.total = 0;
      this.tableData = [];
    },

    // 表单重置
    resetFormData(formName) {
      this.$refs[formName].resetFields();
    },

    // 门店完成率贡献值
    getList() {
      this.loading = true;
      StoreWages(this.queryParams)
        .then((res) => {
          console.log(res);
          this.loading = false;
          const { code, data } = res;
          if (code === 0) {
            this.tableData = data.list;
            this.total = data.total;
          }
        })
        .catch((err) => {
          this.loading = false;
        });
    },

    // 筛选
    handleQuery() {
      this.queryParams.pageNo = 1;
      this.getList();
    },

    /** 重置按钮操作 */
    resetQuery() {
      this.resetFormData("queryForm");
      this.handleQuery();
    },

    // 表单重置
    resetFormData(formName) {
      console.log(this.$refs[formName]);
      this.$refs[formName].resetFields();
    },
  },
};
</script>

<style lang="scss" scoped>
.w-200 {
  width: 200px;
  background: #ffffff;
  border-radius: 4px;
}

.client_name {
  font-size: 14px;
  font-weight: 400;
  color: #0052d9;
}

.give {
  height: 40px;
  font-size: 14px;
  font-weight: 400;
  color: rgba(0, 0, 0, 0.85);
  margin-top: 40px;
  line-height: 40px;
}

.el-form-item {
  margin-bottom: 20px;
}

.recharge_form {
  padding: 10px 24px;
}

.memberName {
  font-size: 14px;
  font-weight: 400;
  color: rgba(0, 0, 0, 0.85);
}
.el_row_item {
  margin-bottom: 10px;
}
.el_row_date {
  margin-top: 20px;
}
.el_row_reason {
  margin-top: 10px;
}

.el_row_date {
  .el-form-item {
    margin-bottom: 0px;
  }
}

.separate_left {
  width: 1px;
  height: 14px;
  // background: #e9e9e9;
  margin-right: 12px;
}
.separate_right {
  width: 1px;
  height: 14px;
  // background: #e9e9e9;
  margin-left: 12px;
}

.check {
  font-size: 12px;
  color: #0052d9;
}

.list_Stores {
  height: 22px;
  font-size: 14px;
  font-weight: 400;
  color: rgba(0, 0, 0, 0.9);
  line-height: 22px;
  .list_Stores_item {
    height: 46px;
    line-height: 46px;
    background: #ffffff;
    padding-left: 47px;
    border-bottom: 1px solid #e7e7e7;
  }
}

.AddRules_box {
  padding: 0 24px;
  .Rules_form_box {
    display: flex;
    .Rules_form_select {
      margin-right: 10px;
    }
  }
}

.radio_box {
  display: flex;
  margin-bottom: 10px;
}

.up_ipt {
  width: 300px;
  margin-right: 20px;
}
.down_ipt {
  width: 300px;
  margin-left: 10px;
}
.percentIcon {
  position: absolute;
  top: 55px;
  right: -15px;
}

.red {
  color: red;
}
.green {
  color: green;
}

.selectBox {
  margin-bottom: 20px;
}

.percentBox {
  display: flex;
  align-items: center;

  .IptNumber {
    width: 100%;
    margin-right: 10px;
  }
}
</style>
